﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Drawing;

namespace Line64.ImageFlow.Activities
{

    public sealed class DrawTextActivity : CodeActivity
    {

        public InOutArgument<Bitmap> Bitmap { get; set; }

        public InArgument<string> Text { get; set; }

        public InArgument<PointF> Position { get; set; }

        public InArgument<Font> Font { get; set; }

        public InArgument<Brush> Brush { get; set; }

        protected override void Execute(CodeActivityContext context)
        {            

            Bitmap bitmap = this.Bitmap.Get(context);
            string text = this.Text.Get(context);
            PointF position = this.Position.Get(context);
            Font font = this.Font.Get(context);
            Brush brush = this.Brush.Get(context);

            Graphics g = Graphics.FromImage(bitmap);

            g.DrawString(text, font, brush, position);

            this.Bitmap.Set(context, bitmap);

        }

    }

}